const bodyParser = require("koa-bodyparser");
const cors = require("koa2-cors");
const render = require("koa-art-template");
const static = require("koa-static")

const router = require("../routers/index.js")//获取文件

function initManage(app){
    // console.log(process.cwd())//打印地址
    app.use(cors());
    app.use(bodyParser());
    render(app,{
        // root:resolve(__dirname,'views'),
        root:`${process.cwd()}/views`,
        extname:'.html',//后缀也可以写成.art
        debug:process.env.NODE_ENV !== 'production'
    });
    app.use(static(`${process.cwd()}/static`));//进入图片地址不需要加static
    //http://localhost:8080/file-177d8d35dd0.jpg图片地址
    app.use(router.routes());
}
module.exports = initManage;